package com.itr.kbm.dao.impl;

import java.util.List;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.itr.kbm.dao.UserDao;
import com.itr.kbm.model.User;

@Repository
public class UserDaoImpl extends AbstractDaoImpl<User, String> implements UserDao {

    protected UserDaoImpl() {
        super(User.class);
    }

	public User login(String username) {
		Criterion crit = Restrictions.eq("username", username);
		
		List<User>users = findByCriteria(crit);
		
		User user = users!=null && users.size()==1 ? users.get(0) : null;
		
		return user;
	}
	
}
